
#include "typedef.h"
//#define DECODE_BUFFER       dec_msg->buffer//((u8 _xdata *)0x2c00)

#define MP2EN_HEADER_ADDR       0x6030
#define MP2EN_MAIN_ADDR         0x3080	//6700
			

#define MP2ENCODEDATA   0x4f88	   //0x6118	
#define MP2ENCODEDATAH  0x87c4	   //0x908c
	  
#define MP2ENCODECFG    0x6008	   //0x785c	 

#define MP2ENCODETAB    0x4f84     //0X4E00   
#define MP2ENCODETABH   0x87c2     //0X8700   

#define MP2ENCODETAB1    0x493e     //0X4E00   
#define MP2ENCODETAB1H   0x849f     //0X8700 





#define DSP_QUANTIZE_ADDR  0x2588//0x2510
#define DSP_SYNTH_ADDR     0x2484//0x2400

typedef struct _MpegContext 
{
    u8 nb_channels;
    u16 freq; 
	u16 bit_rate;
    u8 lsf;           /* 1 if mpeg2 low bitrate selected */
    u8 bitrate_index; /* bit rate */
    u8 freq_index;
    u16 frame_size; /* frame size, in bits, without padding */
    u8 padding;
	u8 sblimit;
    u8 *alloc_sb;
	u8 *alloc_table;
	u8 *sf_ptr;
	u8 headerlen;
	u8 sf_bit;
	u8 *data_ptr;
	u8 data_bit;
} MpegContext;

//#define MP3RECBIFFER  0x06
#define WAV_OUT_BUFFER_SIZE  0x12 
 extern u8 xdata wavparkgenum ;
extern u8 xdata  gr ; 	 
extern s16 xdata frame_len ;
extern u8 xdata writepos ;
extern u8 xdata readpos ;
extern u32 xdata ff_fr_counter;
extern void init_mp2en(void) compact ;
extern u8 mp2encode_init(u16 samp_rate,u16 bit_rate,u8 ch) compact ;
u8 mp2encodeInit(u16 samp_rate,u8 ch,u16 bit_rate) compact  ;


#define MP3PARKPONIT    (32)
#define ADSP_ADC_LEN    (MP3PARKPONIT*2*2*2)
#define REC_OUTPUT_BUFF_LEN   ((2048 - (MP3PARKPONIT*2*2*2))/512)

#define WAVPARKPONIT    128



enum
{
  ENCODE_NO_OPT  = 0,
  SYNTH_WORK,
  QUANTIZE_WORK,
};
extern u8 _idata encode_case;
extern u8 plus_buff_cnt(u8 cnt);